package com.lagou.boot;

import com.lagou.client.RPCConsumer;
import com.lagou.rpc.RpcRequest;
import com.lagou.service.IUserService;

public class ConsumerBoot {

    //参数定义
    private static final String PROVIDER_NAME = "UserService#sayHello#";

    public static void main(String[] args) throws InterruptedException {

        //1.创建代理对象
        IUserService service = (IUserService) RPCConsumer.createProxy(IUserService.class);

        //2.循环给服务器写数据
        while (true){
            try {
                RpcRequest rpcRequest = new RpcRequest();
                rpcRequest.setClassName("com.lagou.rpc.RpcRequest");
                rpcRequest.setMethodName("getMsg");
                rpcRequest.setRequestId("userServiceImpl");
                rpcRequest.setParameters(new Object[]{"Hello------"});
                rpcRequest.setParameterTypes(new Class[]{String.class});
                String result = service.getMsg(rpcRequest);
                System.out.println(result);
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                System.out.println("异常");
            }
        }

    }
}
